package com.cjl.demo.data.structure;

/**
 * <p>Description: </p>
 *
 * @ uthor chenjinliang
 * @ date: 2020/7/29
 */
public class LianbiaoDemo {

    public static void main(String[] args) {
        LianbiaoDemo.Node node1 = new LianbiaoDemo().new Node(1, null);
        LianbiaoDemo.Node node2 = new LianbiaoDemo().new Node(1, node1);
        LianbiaoDemo.Node node3 = new LianbiaoDemo().new Node(1, node2);
        LianbiaoDemo.Node node4 = new LianbiaoDemo().new Node(1, node3);
        LianbiaoDemo.Node node5 = new LianbiaoDemo().new Node(1, node4);
        node4.next = node5;
        System.out.println("args = [" + lianbiao(node5) + "]");

    }
    public static boolean lianbiao(Node header){
        if(null == header || null == header.next){
            return false;
        }
        Node first = header;
        Node secend = header.next;
        while (first != secend ){
            if(null == first || null == secend ||null == secend.next ){
                return false;
            }
            first = first.next;
            secend = secend.next.next;
        }
        return true;
    }

    class Node{
        int value;
        Node next;
        public Node(int value, Node next){
            this.value = value;
            this.next = next;
        }
    }
}
